﻿#ifndef USERENTITY_H
#define USERENTITY_H
#include <QJsonObject>
#include <QString>
#include "ISerializable.h"
#include <IDatabase.h>

#define WORKERID "workerid"
#define WORKERNAME "workername"
#define WORKERPASSWORD "workerpassword"
#define NEWWORKERPASSWORD "newworkerpassword"
#define WORKERLEVEL "workerlevel"

enum WorkerLevel{
    WL_GUEST=0, //访客或缺省值
    WL_OPERATOR,//操作员
    WL_ADMIN,   //管理员
    WL_SUPERADMIN,//超级管理员
    WL_ROOT//超级管理员
};
Q_DECLARE_METATYPE(WorkerLevel)

static QMap<WorkerLevel,QString> mapWorkerLevelName={{WL_ROOT,QObject::tr(u8"root")}
                                                     ,{WL_SUPERADMIN,QObject::tr(u8"超级管理员")}
                                                     ,{WL_ADMIN,QObject::tr(u8"管理员")}
                                                     ,{WL_OPERATOR,QObject::tr(u8"操作员")}
                                                     ,{WL_GUEST,QObject::tr(u8"游客")}};

class UserEntity : public ISerializable
{
public:
    UserEntity();
    // ISerializable interface
public:
    virtual QVariant toVariant() const override;
    virtual void fromVariant(const QVariant &variant) override;

public:
    QString mId;//随机ID 唯一
    QString mWorkID;//工号ID
    QJsonObject mData;//账户数据,包含姓名，密码，用户权限等级，0为超级管理员，1为管理员，2为操作员。
};

#endif // USERENTITY_H
